#include "mainwindow.h"
#include "ui_mainwindow.h"

// 菜单按钮选项及右键菜单选项 初始化
void MainWindow::Menu_Init()
{
    RightMenu = new QMenu();

    ActSelAll = new QAction(this);
    ActCopy = new QAction(this);
    ActPaste = new QAction(this);
    ActClear = new QAction(this);

    if(LangureStu == 1)
    {
        ActSelAll->setText("Select all");
        ActCopy->setText("Copy");
        ActPaste->setText("Paste");
        ActClear->setText("Clear");
    }
    else
    {
        ActSelAll->setText("选择全部");
        ActCopy->setText("复制");
        ActPaste->setText("粘贴");
        ActClear->setText("清除全部");
    }

    connect(ActSelAll, &QAction::triggered, this, &MainWindow::Menu_Option_SelectAll);
    connect(ActCopy,   &QAction::triggered, this, &MainWindow::Menu_Option_Copy);
    connect(ActPaste,  &QAction::triggered, this, &MainWindow::Menu_Option_Paste);
    connect(ActClear,  &QAction::triggered, this, &MainWindow::Menu_Option_Clear);

    RightMenu->addAction(ActSelAll);
    RightMenu->addAction(ActCopy);
    RightMenu->addAction(ActPaste);
    RightMenu->addAction(ActClear);

    //新建右键菜单-写盖板码
    RightMenu_Write = new QMenu();
    ActDevData = new QAction(this);
    if(LangureStu == 1)
    {
        ActDevData->setText("Replace underlying");
    }
    else
    {
        ActDevData->setText("替换底层");
    }
    connect(ActDevData, &QAction::triggered, this, &MainWindow::DevData_to_Btn_Mtsn_Write_RightClicked);
    RightMenu_Write->addAction(ActDevData);
    //
    Right_Write_dlbox = new QMenu();
    ActDevData_dlbox = new QAction(this);
    if(LangureStu == 1)
    {
        ActDevData_dlbox->setText("Replace underlying");
    }
    else
    {
        ActDevData_dlbox->setText("替换底层");
    }
    connect(ActDevData_dlbox, &QAction::triggered, this, &MainWindow::DevData_to_Btn_Mtsn_Write_Dlbox_RightClicked);
    Right_Write_dlbox->addAction(ActDevData_dlbox);

    //新建菜单按钮下拉菜单
    BtnMenuMenu = new QMenu(this);
    MenuDrive   = new QMenu(this);
    MenuTPTools = new QMenu(this);

    //新建action
    AutoUpgFile = new QAction(this);
    ActD341A = new QAction(this);
    ActD341Ser = new QAction(this);
    ActPL23 = new QAction(this);
    ActPL23W11 = new QAction(this);
    ActD343Ser = new QAction(this);
    ActHelp = new QAction(this);
    ImportFile = new QAction(this);
    AboutUs = new QAction(this);
    ActTPTools = new QAction(this);
    Act3uTools = new QAction(this);
    ActI4 = new QAction(this);
    ActShaLou = new QAction(this);

    connect(ActD341A, &QAction::triggered, this, &MainWindow::Menu_Option_Drive341A_clicked);
    connect(ActD341Ser, &QAction::triggered, this, &MainWindow::Menu_Option_Drive341Ser_clicked);
    connect(ActPL23, &QAction::triggered, this, &MainWindow::Menu_Option_DrivePL23_clicked);
    connect(ActPL23W11, &QAction::triggered, this, &MainWindow::Menu_Option_DrivePL23W11_clicked);
    connect(ActD343Ser, &QAction::triggered, this, &MainWindow::Menu_Option_Drive343Ser_clicked);

    connect(Act3uTools, &QAction::triggered, this, &MainWindow::Menu_Option_TPTools_3uTools_Clicked);
    connect(ActI4,      &QAction::triggered, this, &MainWindow::Menu_Option_TPTools_I4_Clicked);
    connect(ActShaLou,  &QAction::triggered, this, &MainWindow::Menu_Option_TPTools_ShaLou_Clicked);

    connect(AutoUpgFile,  &QAction::triggered, this, &MainWindow::Menu_Option_Force_Upgrade_File_clicked);

    connect(ImportFile,  &QAction::triggered, this, &MainWindow::Menu_Option_Import_Upgrade_File);

    connect(ActHelp,      &QAction::triggered, this, &MainWindow::ActHelp_to_Disp);
    connect(AboutUs,      &QAction::triggered, this, &MainWindow::Menu_Option_AboutUs_clicked);

    if(LangureStu == 1)
    {
        ActD341A->setText("Fxxx Drive Install");
        ActD341Ser->setText("Fxxx Drive Install(Win7)");
        ActPL23->setText("DL400 Drive Install");
        ActPL23W11->setText("DL400 Drive Install(Win11)");
        ActD343Ser->setText("New DL400 Drive Install");
        ActTPTools->setText("Third-party tools");
        Act3uTools->setText("3uTools");
        ActI4->setText("i4Tools");
        ActShaLou->setText("ShaLou");
        AutoUpgFile->setText("Force upgrade");
        ImportFile->setText("Import file");
        ActHelp->setText("Help");
        AboutUs->setText("About");
    }
    else
    {
        ActD341A->setText("Fxxx驱动安装");
        ActD341Ser->setText("Fxxx驱动安装(Win7)");
        ActPL23->setText("DL400驱动安装");
        ActPL23W11->setText("DL400驱动安装(Win11)");
        ActD343Ser->setText("新版DL400驱动安装");
        ActTPTools->setText("第三方工具");
        Act3uTools->setText("3uTools");
        ActI4->setText("爱思助手");
        ActShaLou->setText("沙漏助手");
        AutoUpgFile->setText("强制升级");
        ImportFile->setText("导入升级文件");
        ActHelp->setText("帮助");
        AboutUs->setText("关于");
    }

    //把action追加到menu
    MenuDrive->addAction(ActD341A);
    MenuDrive->addAction(ActD341Ser);
    MenuDrive->addAction(ActPL23);
    MenuDrive->addAction(ActPL23W11);
    MenuDrive->addAction(ActD343Ser);
    
    MenuTPTools->addAction(Act3uTools);
    MenuTPTools->addAction(ActI4);
    MenuTPTools->addAction(ActShaLou);
    ActTPTools->setMenu(MenuTPTools);
    BtnMenuMenu->addAction(ActTPTools);
    BtnMenuMenu->addAction(AutoUpgFile);
#ifdef __IMPORT_FILE_DEBUG
    BtnMenuMenu->addAction(ImportFile);
#endif
#ifdef __ACT_HELP
    BtnMenuMenu->addAction(ActHelp);
#endif
    BtnMenuMenu->addAction(AboutUs);
}

//关闭
void MainWindow::on_btn_menu_close_clicked()
{
    this->close();
}
//最大化
void MainWindow::on_btn_menu_max_clicked()
{
    static bool max = false;
    static QRect location = this->geometry();

    if (max) {
        MaxStu = 0;
        this->setGeometry(location);
        ui->btn_menu_max->setIcon(QIcon(":/image/max.png"));
        if(LangureStu == 1)
        {
            ui->btn_menu_max->setToolTip("Maximize");
        }
        else
        {
            ui->btn_menu_max->setToolTip("最大化");
        }
    } else {
        MaxStu = 1;
        location = this->geometry();
        this->setGeometry(QUIHelper::getScreenRect());
        ui->btn_menu_max->setIcon(QIcon(":/image/res.png"));
        if(LangureStu == 1)
        {
            ui->btn_menu_max->setToolTip("Maximize");
        }
        else
        {
            ui->btn_menu_max->setToolTip("Reduction");
        }
    }

    this->setProperty("canMove", max);
    max = !max;
}
//最小化
void MainWindow::on_btn_menu_min_clicked()
{
    this->showMinimized();
}
//菜单按钮
void MainWindow::on_btn_menu_menu_clicked()
{
    //把menu加载到button
    ui->btn_menu_menu->setMenu(BtnMenuMenu);

    //打开menu
    BtnMenuMenu->exec(QPoint(QCursor::pos().x(),QCursor::pos().y()));
}
// 驱动按钮
void MainWindow::on_btn_menu_drive_clicked()
{
    //把menu加载到button
    ui->btn_menu_drive->setMenu(MenuDrive);

    //打开menu
    MenuDrive->exec(QPoint(QCursor::pos().x(),QCursor::pos().y()));
}
// 语言切换按钮
void MainWindow::on_btn_menu_langure_clicked()
{
    ui->te_prin->clear();
    ui->te_prin_disp_f210->clear();
    ui->te_prin_f316->clear();
    ui->te_prin_dlbox->clear();
    ui->te_prin_dl8000->clear();
    if(LangureStu == 1)
    {
        ActD341A->setText("Fxxx驱动安装");
        ActD341Ser->setText("Fxxx驱动安装(Win7)");
        ActPL23->setText("DL400驱动安装");
        ActPL23W11->setText("DL400驱动安装(Win11)");
        ActTPTools->setText("第三方工具");
        Act3uTools->setText("3uTools");
        ActI4->setText("爱思助手");
        ActShaLou->setText("沙漏助手");
        AutoUpgFile->setText("强制升级");
        ActHelp->setText("帮助");
        AboutUs->setText("关于");

        ActSelAll->setText("选择全部");
        ActCopy->setText("复制");
        ActPaste->setText("粘贴");
        ActClear->setText("清除");
        LangureStu = 0;
    }
    else
    {
        ActD341A->setText("Fxxx Drive Install");
        ActD341Ser->setText("Fxxx Drive Install(Win7)");
        ActPL23->setText("DL400 Drive Install");
        ActPL23W11->setText("DL400 Drive Install(Win11)");
        ActTPTools->setText("Third-party tools");
        Act3uTools->setText("3uTools");
        ActI4->setText("i4Tools");
        ActShaLou->setText("ShaLou");
        AutoUpgFile->setText("Force upgrade");
        ActHelp->setText("Help");
        AboutUs->setText("About");

        ActSelAll->setText("Select all");
        ActCopy->setText("Copy");
        ActPaste->setText("Paste");
        ActClear->setText("Clear");
        LangureStu = 1;
    }

    //写ini
    QSettings *LangureRead = new QSettings(FilePath+"/cfg/config.ini",QSettings::IniFormat);
    LangureRead->setValue("MainMenu/Language",LangureStu);
    delete LangureRead;

    ui->te_prin->clear();

    //控件设置文字
    Btn_Link_Langure_to_Change(ui->btn_link);
    Btn_Link_Langure_to_Change(ui->btn_link_bat);
    Btn_Link_Langure_to_Change(ui->btn_link_dlbox);
    Btn_Link_Langure_to_Change(ui->btn_link_disp_f210);
    Btn_Link_Langure_to_Change(ui->btn_link_f316);
    Btn_Link_Langure_to_Change(ui->btn_link_dl8000);

    //控件设置文字
    App_Langure_to_Change();
    Lbl_Ver_Langure_to_Change();
	Lbl_Ver_F316_Langure_to_Change();
	Lbl_Ver_dl8000_Langure_to_Change();
}
// 菜单按钮-强制升级
void MainWindow::Menu_Option_Force_Upgrade_File_clicked()
{
    if(PORT_STU_NULL != PortStu && PORT_STU_SYNC != PortStu)
    {
        int LastUpgStu = UpgStu;
        UpgStu = 2;
        on_btn_upg_clicked();
        UpgStu = LastUpgStu;
    }
}
// 菜单按钮-驱动升级
void MainWindow::Menu_Option_Drive341A_clicked()
{
    QProcess* ProcD341A = new QProcess;
    bool StartStu;
    ProcD341A->setWorkingDirectory(FilePath);
    LangureStr = FilePath + "/Drivers/CH341SER/SETUP.EXE";
    StartStu = ProcD341A->startDetached(QString("%1").arg(LangureStr),QStringList(LangureStr));
    if(!StartStu)
    {
        // 错误提示
    }
}
// 菜单按钮-驱动升级(用于部分Win7用户)
void MainWindow::Menu_Option_Drive341Ser_clicked()
{
    QProcess* ProcD341Ser = new QProcess;
    bool StartStu;
    ProcD341Ser->setWorkingDirectory(FilePath);
    LangureStr = FilePath + "/Drivers/CH341SER.EXE";
    StartStu = ProcD341Ser->startDetached(QString("%1").arg(LangureStr),QStringList(LangureStr));
    if(!StartStu)
    {
        // 错误提示
    }
}
// 菜单按钮-测试盒驱动升级
void MainWindow::Menu_Option_DrivePL23_clicked()
{
    QProcess* ProcDPL23 = new QProcess;
    bool StartStu;
    ProcDPL23->setWorkingDirectory(FilePath);
    LangureStr = FilePath + "/Drivers/PL2303_v110.exe";
    StartStu = ProcDPL23->startDetached(QString("%1").arg(LangureStr),QStringList(LangureStr));
    if(!StartStu)
    {
        // 错误提示
    }
}
// 菜单按钮-测试盒驱动升级(用于Win11用户)
void MainWindow::Menu_Option_DrivePL23W11_clicked()
{
    QProcess* ProcDPL23W11 = new QProcess;
    bool StartStu;
    ProcDPL23W11->setWorkingDirectory(FilePath);
    LangureStr = FilePath + "/Drivers/PL23XX_Win11.exe";
    StartStu = ProcDPL23W11->startDetached(QString("%1").arg(LangureStr),QStringList(LangureStr));
    if(!StartStu)
    {
        // 错误提示
    }
}
void MainWindow::Menu_Option_Drive343Ser_clicked()
{
    QProcess* ProcD343Ser = new QProcess;
    bool StartStu;
    ProcD343Ser->setWorkingDirectory(FilePath);
    LangureStr = FilePath + "/Drivers/CH343SER/SETUP.EXE";
    StartStu = ProcD343Ser->startDetached(QString("%1").arg(LangureStr),QStringList(LangureStr));
    if(!StartStu)
    {
        // 错误提示
    }
}
// 菜单按钮-3uTools
void MainWindow::Menu_Option_TPTools_3uTools_Clicked()
{
    QString Url3uTools = "http://www.3u.com/";
    OpenUrl(Url3uTools);
}
// 菜单按钮-I4助手
void MainWindow::Menu_Option_TPTools_I4_Clicked()
{
    QString UrlI4 = "https://www.i4.cn/";
    OpenUrl(UrlI4);
}
// 菜单按钮-沙漏助手
void MainWindow::Menu_Option_TPTools_ShaLou_Clicked()
{
    QString UrlShaLou = "http://www.shalou.net/home";
    OpenUrl(UrlShaLou);
}

// F210-提示框添加右键菜单
void MainWindow::on_te_prin_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_Te_Prin;
    ActPaste->setEnabled(false);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}
// F210-文件框添加右键菜单
void MainWindow::on_te_file_write_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_Le_Write;
    ActPaste->setEnabled(true);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}
// F210-盖板码框添加右键菜单
void MainWindow::on_te_mtsn_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_te_mtsn;
    ActPaste->setEnabled(true);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}

// F210显示修复-提示框添加右键菜单
void MainWindow::on_te_prin_disp_f210_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_Te_Disp_F210;
    ActPaste->setEnabled(false);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}

// F210电池修复-提示框添加右键菜单
void MainWindow::on_te_prin_bat_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_Te_Prin;
    ActPaste->setEnabled(false);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}

// 测试盒-提示框添加右键菜单
void MainWindow::on_te_prin_dlbox_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_Pte_Recv_Dlbox;
    ActPaste->setEnabled(false);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}
// 测试盒-盖板码框添加右键菜单
void MainWindow::on_te_mtsn_dlbox_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_Te_Mtsn_Dlbox;
    ActPaste->setEnabled(true);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}
// 测试盒-文件框添加右键菜单
void MainWindow::on_te_file_write_dlbox_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_Le_Write_Dlbox;
    ActPaste->setEnabled(true);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}

// F316-提示框添加右键菜单
void MainWindow::on_te_prin_f316_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_Te_Prin_F316;
    ActPaste->setEnabled(false);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}

// dl8000-盖板码框添加右键菜单
void MainWindow::on_te_mtsn_dl8000_customContextMenuRequested(const QPoint &pos)
{
    MenuStu = Type_te_mtsn_dl8000;
    ActPaste->setEnabled(true);
    if(RightMenu)
    {
        RightMenu->exec(QCursor::pos());
    }
}

void MainWindow::Menu_Option_Clear()
{
    switch(MenuStu) {
    case Type_Te_Prin: ui->te_prin->clear(); break;
    case Type_te_mtsn: ui->te_mtsn->clear(); break;
    case Type_Le_Write: ui->te_file_write->clear(); break;
    case Type_Pte_Recv_Dlbox: ui->te_prin_dlbox->clear(); break;
    case Type_Te_Mtsn_Dlbox: ui->te_mtsn_dlbox->clear(); break;
    case Type_Le_Write_Dlbox: ui->te_file_write_dlbox->clear(); break;
    case Type_Te_Disp_F210: ui->te_prin_disp_f210->clear(); break;
    case Type_Te_Bat_F210:  ui->te_prin_bat->clear(); break;
    case Type_Te_Prin_F316:  ui->te_prin_f316->clear(); break;
    case Type_te_mtsn_dl8000: ui->te_mtsn_dl8000->clear(); break;
    }
}
void MainWindow::Menu_Option_Paste()
{
    switch(MenuStu) {
    case Type_Te_Prin_F316:
    case Type_Te_Bat_F210:
    case Type_Te_Disp_F210:
    case Type_Pte_Recv_Dlbox:
    case Type_Te_Prin: break;
    case Type_te_mtsn: ui->te_mtsn->paste(); break;
    case Type_Le_Write: ui->te_file_write->paste(); break;
    case Type_Te_Mtsn_Dlbox: ui->te_mtsn_dlbox->paste(); break;
    case Type_Le_Write_Dlbox: ui->te_file_write_dlbox->paste(); break;
    case Type_te_mtsn_dl8000: ui->te_mtsn_dl8000->paste(); break;
    }
}
void MainWindow::Menu_Option_Copy()
{
    switch(MenuStu) {
    case Type_Te_Prin: ui->te_prin->copy(); break;
    case Type_te_mtsn: ui->te_mtsn->copy(); break;
    case Type_Le_Write: ui->te_file_write->copy(); break;
    case Type_Pte_Recv_Dlbox: ui->te_prin_dlbox->copy(); break;
    case Type_Te_Mtsn_Dlbox: ui->te_mtsn_dlbox->copy(); break;
    case Type_Le_Write_Dlbox: ui->te_file_write_dlbox->copy(); break;
    case Type_Te_Disp_F210: ui->te_prin_disp_f210->copy(); break;
    case Type_Te_Bat_F210:  ui->te_prin_bat->copy(); break;
    case Type_Te_Prin_F316: ui->te_prin_f316->copy(); break;
    case Type_te_mtsn_dl8000: ui->te_mtsn_dl8000->copy(); break;
    }
}
void MainWindow::Menu_Option_SelectAll()
{
    switch(MenuStu) {
    case Type_Te_Prin: ui->te_prin->selectAll(); break;
    case Type_te_mtsn: ui->te_mtsn->selectAll(); break;
    case Type_Le_Write: ui->te_file_write->selectAll(); break;
    case Type_Pte_Recv_Dlbox: ui->te_prin_dlbox->selectAll(); break;
    case Type_Te_Mtsn_Dlbox: ui->te_mtsn_dlbox->selectAll(); break;
    case Type_Le_Write_Dlbox: ui->te_file_write_dlbox->selectAll(); break;
    case Type_Te_Disp_F210: ui->te_prin_disp_f210->selectAll(); break;
    case Type_Te_Bat_F210:  ui->te_prin_bat->selectAll(); break;
    case Type_Te_Prin_F316: ui->te_prin_f316->selectAll(); break;
    case Type_te_mtsn_dl8000: ui->te_mtsn_dl8000->selectAll(); break;
    }
}

// 关于我们
void MainWindow::Menu_Option_AboutUs_clicked()
{
    QWidget* wdg_about = new QWidget();
    QLabel *lbl_about = new QLabel();
    QLabel *lbl_comp = new QLabel();
    QLabel *lbl_vers = new QLabel();

    QVBoxLayout* vlyt_about = new QVBoxLayout(wdg_about);

    wdg_about->setWindowFlags(Qt::WindowCloseButtonHint);
    wdg_about->resize(240,300);
    wdg_about->setMaximumSize(240,280);
    wdg_about->setMinimumSize(240,280);
    wdg_about->setStyleSheet("background:#FFFFFF;");
    if(LangureStu == 1)
    {
        wdg_about->setWindowTitle("About");
    }
    else
    {
        wdg_about->setWindowTitle("关于");
    }
    //添加标签至布局
    vlyt_about->addWidget(lbl_about);
    vlyt_about->addWidget(lbl_comp);
    vlyt_about->addWidget(lbl_vers);
    vlyt_about->setContentsMargins(30,30,30,30);
    //设置图标
    QImage *img=new QImage; //新建一个image对象
    img->load(":/image/256ico.ico");
    lbl_about->setMaximumSize(160, 150);
    lbl_about->setMinimumSize(160, 150);
    lbl_about->setPixmap(QPixmap::fromImage(*img));
    lbl_about->setScaledContents(true);
    //
    lbl_comp->setOpenExternalLinks(true);
    if(LangureStu == 1)
    {
#if 0
        lbl_comp->setText("<style> a {text-decoration: none} </style><a style='color: blue;' href=\"http://szdianliang.com\">DLZN Technology \nCo., Ltd");
#else
        lbl_comp->setText("DLZN Technology \nCo., Ltd");
#endif
        lbl_vers->setText("Version "+AppVers);
    }
    else
    {
#if 0
        lbl_comp->setText("<style> a {text-decoration: none} </style><a style='color: blue;' href=\"http://szdianliang.com\">点亮智能科技有限公司");
#else
        lbl_comp->setText("点亮智能科技有限公司");
#endif
        lbl_vers->setText("版本 "+AppVers);
    }
    lbl_comp->setAlignment(Qt::AlignCenter);
    lbl_vers->setAlignment(Qt::AlignCenter);
    wdg_about->setWindowModality(Qt::ApplicationModal);
    wdg_about->show();
}

// 右键菜单-替换底层
void MainWindow::on_btn_mtsn_write_customContextMenuRequested(const QPoint &pos)
{
    if(RightMenu_Write)
    {
        RightMenu_Write->exec(QCursor::pos());
    }
}

// 替换底层
void MainWindow::DevData_to_Btn_Mtsn_Write_RightClicked()
{
    if(!Check_cbx_model_read_Must_Select(ui->cbx_model_read, ui->te_prin))
    {
        return;
    }
    SyncTimer->stop();
    Port_Function_Lock_Or_Unlock(DISP_BTN_LOCK_ALL);

    if(Mtsn_Write_to_Mcu(SEND_BURN_MTSN_DEV))
    {
        LangureStr_Init_BurnCode_DevData_Succeed(ui->te_prin);
        Port_Function_Lock_Or_Unlock(DISP_BTN_LOCK_RES);
    }
    else
    {
        Port_Function_Lock_Or_Unlock(DISP_BTN_UNLOCK_ALL);
    }

    SyncTimer->start(TIMER_SYNC_TIME_OUT);

    if(PORT_STU_NULL == PortStu)
    {
        LangureStr_Init_Btn_Unlink(ui->btn_link);
		LangureStr_Init_Btn_Unlink(ui->btn_link_bat);
        on_btn_link_clicked();
    }
}
// 替换底层
void MainWindow::DevData_to_Btn_Mtsn_Write_Dlbox_RightClicked()
{
    Dlbox_MtsnCode_Write(true);

    // 若设备未断开，则恢复按钮组状态及开启同步定时器
    if(ConnectStu_dlbox && ConnectStu_dlbox)
    {
        Dlbox_Btn_Lock_Or_Unlock(DISP_BTN_LOCK_RES);
        SyncTimer_dlbox->start(5000);
    }
}

//
void MainWindow::on_btn_mtsn_write_dlbox_customContextMenuRequested(const QPoint &pos)
{
    if(Right_Write_dlbox)
    {
        Right_Write_dlbox->exec(QCursor::pos());
    }
}

